//
//  UIButton+Extension.swift
//  sinaWeiBoGui
//
//  Created by liyonggui on 16/5/17.
//  Copyright © 2016年 liyonggui. All rights reserved.
//

import UIKit



extension UIButton {
    
    convenience init(bkgImageName: String, imageName: String, title: String, titleColor: UIColor = UIColor.lightGrayColor(), fontSize: CGFloat = 12) {
        
        self.init(type: UIButtonType.Custom)
        
        // 背景图片
        setBackgroundImage(UIImage(named: bkgImageName), forState: UIControlState.Normal)
        setBackgroundImage(UIImage(named: "\(bkgImageName)_highlighted"), forState: UIControlState.Highlighted)
        // 图片
        setImage(UIImage(named: imageName), forState: UIControlState.Normal)
        // 字体
        setTitle(title, forState: UIControlState.Normal)
        setTitleColor(titleColor, forState: UIControlState.Normal)
        // 字体大小
        titleLabel?.font = UIFont.systemFontOfSize(fontSize)
    }
}






